#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <unordered_map>

#include "SmartSerial.h"
#include "AT/AT.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow() override;

    void initMap();
    std::unordered_map<std::string, std::string> phoneCCID;
    std::unordered_map<std::string, std::string> ccidPhone;
    void updateList();

private slots:
    void on_pb_close_clicked();

    void on_pb_open_clicked();

    void on_pb_send_clicked();

    void on_le_phone_editingFinished();

    void on_bp_update_clicked();

    void on_lw_serial_currentRowChanged(int currentRow);

    void on_pb_recv_clicked();

private:
    Ui::MainWindow *ui;
    struct Item {
        int id;
        std::string port;
        std::string ccid;
        std::string phone;

        std::shared_ptr<SmartSerial> serial;
        std::shared_ptr<AT> at;
    };
    std::vector<std::shared_ptr<Item>> items;
    std::shared_ptr<Item> itemFound;
};
#endif // MAINWINDOW_H
